package org.dandsoft.blackbox.laboratory.tests.streamer;

import org.dandsoft.blackbox.SignalId;

import java.util.List;
import java.util.ArrayList;

/**
 * @author Vilyuzhanin Denis (Fin)
 */
public class Trigger {
    private SignalId signalId;
    private List<SignalId> template = new ArrayList<SignalId>();
    private int waitSignal;

    public void reset() {
        waitSignal = 0;
    }

    public SignalId getSignalId() {
        return signalId;
    }

    public void setSignalId(SignalId signalId) {
        this.signalId = signalId;
    }

    public boolean parse(SignalId signal) {
        if (signal.equals(template.get(waitSignal))) {
            waitSignal++;
            return true;
        } else {
            return false;
        }
    }

    public List<SignalId> getTemplate() {
        return template;
    }

    public int getAccurancy() {
        return waitSignal * 100 / template.size();
    }

    public int getWaitSignal() {
        return waitSignal;
    }

    public boolean isFinished() {
        return template.size() == waitSignal;
    }
}
